package com.myidis.controller;

import java.util.ArrayList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.myidis.entity.QuotaType;
import com.myidis.servlet.QuotaTypeServlet;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Controller
@RequestMapping("/type")
@Api(tags = "指标类型管理接口")
public class QuotaTypeController {

	@Autowired
	private QuotaTypeServlet typeServlet;

	@ResponseBody
	@RequestMapping("/list")
	@ApiOperation("获取所有指标类型信息")
	public ArrayList<QuotaType> ArrayList() {
		return typeServlet.all();
	}

	@ResponseBody
	@RequestMapping("/entity")
	@ApiOperation("获取一个指标类型信息")
	public QuotaType one(@RequestBody QuotaType quotaType) {
		return typeServlet.getOne(quotaType.getId());
	}

	@ResponseBody
	@RequestMapping("/add")
	@ApiOperation("添加一个指标类型信息")
	public int add(@RequestBody QuotaType quotaType) {
		return typeServlet.insert(quotaType);
	}
	
	@ResponseBody
	@RequestMapping("/addAll")
	@ApiOperation("添加一组指标类型信息")
	public int addAll(@RequestBody ArrayList<QuotaType> quotaTypes) {
		return typeServlet.insertAll(quotaTypes);
	}
	
	@ResponseBody
	@RequestMapping("/upd")
	@ApiOperation("修改一个指标类型信息")
	public int upd(@RequestBody QuotaType quotaType) {
		return typeServlet.update(quotaType);
	}

	@ResponseBody
	@RequestMapping("/del")
	@ApiOperation("删除一个指标类型信息")
	public int del(@RequestBody int id) {
		return typeServlet.delete(id);
	}
	
	@ResponseBody
	@RequestMapping("/delAll")
	@ApiOperation("删除一组指标类型信息")
	public int delAll(@RequestBody int[] ids) {
		return typeServlet.deleteAll(ids);
	}
}
